
import path from "path";
const HtmlWebpackPlugin = require("html-webpack-plugin");

// vue-loader 配套插件
const {VueLoaderPlugin} = require("vue-loader");
module.exports = {
    mode: "development",
    devtool: 'source-map',
    entry: path.resolve(__dirname, './index.ts'),
    output: {
        path: path.resolve(__dirname, './dist'),
        filename: '[name]_[hash:8].[ext]',
    }
    ,
    resolve: {
        // 解析模块
        extensions: ['.ts', '.tsx', '.js', '.vue'] 
    },
    module: {
        rules: [
            {
                test: /\.(ts|js)x?$/,
                exclude: /node_modules/,
                loader: "babel-loader", // 用这个需要.babelrc
            },
            {
                test: /\.vue$/,
                loader: 'vue-loader',
            },
            {
                test: /\.(svg|otf|ttf|woff)$/,
                loader: 'url-loader',
            },
            {
                test: /\.(scss|css)$/,
                use: [
                    'style-loader',
                    'css-loader',
                    'sass-loader',
                ]
            }
        ]
    },
    plugins: [
        new VueLoaderPlugin(),
        new HtmlWebpackPlugin({
            template: path.resolve(__dirname, 'template.html'),
        }),
    ]
}